<template>
	<view>
		<!-- <u-navbar title="运费" :is-back="false"></u-navbar> -->
		<view v-for="item in list" class="item">
			<view class="top u-flex u-row-between">
				<view>{{item.name}}</view>
				<view class="u-flex">
					<image class="del" @click="delfreigh(item.id)" src="@/static/wImg/delGrey.png"></image>
					<image class="edit" @click="$func.jump('/wNew/pages/addTemplate?id='+item.id)"
						src="@/static/wImg/editGrey.png"></image>
				</view>
			</view>
			<view class="bot" v-for="(items,indexs) in item.children" :key="indexs">
				<view class="zi">{{item.isdelivery==1?'包邮':'可配送地区'}}</view>
				<view class="address"  style="display: flex;flex-wrap: wrap;" v-if="item.isdelivery != 1">
					<view class="" style="display: flex;flex-wrap: wrap;">
						<view class="" v-for="(itemd,indexd) in items.address" :key="indexs">{{itemd}}</view>
					</view>
					....
				</view>
				<view class="u-flex u-row-between m-t-30">
					<view class="tit">首件 {{items.first}}件</view>
					<view class="price">运费{{items.first_fee}}元</view>
				</view>
				<view class="u-flex u-row-between m-t-30">
					<view class="tit">续重 {{items.additional}}KG</view>
					<view class="price">运费{{items.additional_fee}}元</view>
				</view>
			</view>
		</view>
		<!-- <mescroll-body :sticky="true" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			
		</mescroll-body> -->
		<view class="btn u-flex-center" @click="$func.jump('/wNew/pages/addTemplate')">
			新增运费模板
		</view>
		<view style="height: 150rpx;"></view>
		<u-tabbar v-model="current" @change="changeTab" height="55px" active-color="#606DCE" inactive-color="#888"
			:list="tabList"></u-tabbar>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				tabList: [{
						iconPath: "https://apishop.qiancdj.com/static/img/home.png",
						selectedIconPath: "https://apishop.qiancdj.com/img/tabber/home.png",
						text: '商品',
					},
					{
						iconPath: "https://apishop.qiancdj.com/static/img/order.png",
						selectedIconPath: "https://apishop.qiancdj.com/img/tabber/category.png",
						text: '订单',
					},
					{
						iconPath: "https://apishop.qiancdj.com/static/img/shen.png",
						selectedIconPath: "https://apishop.qiancdj.com/img/tabber/sh.png",
						text: '审核',
					},
					{
						iconPath: "https://apishop.qiancdj.com/static/img/cart.png",
						selectedIconPath: "https://apishop.qiancdj.com/img/tabber/card.png",
						text: '运费',
					},
					{
						iconPath: "https://apishop.qiancdj.com/static/img/mine.png",
						selectedIconPath: "https://apishop.qiancdj.com/img/tabber/user.png",
						text: '我的',
					},
				],
				current: 3,
				list:[]
			}
		},
		onReady() {
			this.$u.post('/api/shop/get_logistics_list', {
				type : 2
			}).then(res => {
				if (res.code == 1) {
					this.list = res.data.data
					this.MescrollMixin.optDown.use = false;
					this.MescrollMixin.optUp.textNoMore = '- 已经到底啦 -'
				}
			})
		},
		methods: {
			delfreigh(id){
				this.$u.post('/api/shop/del_logistics', {
					ids : id
				}).then(res => {
					if (res.code == 1) {
						uni.$u.toast('删除成功')
						this.$u.post('/api/shop/get_logistics_list', {
							type : 2
						}).then(res => {
							if (res.code == 1) {
								this.list = res.data.data
								this.MescrollMixin.optDown.use = false;
								this.MescrollMixin.optUp.textNoMore = '- 已经到底啦 -'
							}
						})
						
					}else if(res.code == 0){
						uni.$u.toast(res.msg)
					}
				})
			},
			upCallback(page) {
				this.MescrollMixin.optDown.use = false;
				this.MescrollMixin.optUp.textNoMore = '- 已经到底啦 -'
				// this.$u.post('/sinology/scholar_detail', {
				// 	page: page.num,
				// 	limit: page.size,
				// 	id: this.id,
				// 	type: this.current > 0 ? this.current : ''
				// }).then(res => {
				// 	this.mescroll.endBySize(res.data.articles.length, res.data.total);
				// 	if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
				// 	this.list = this.list.concat(res.data.articles); //追加新数据
				// 	this.scholar = res.data.scholar
				// }).catch(() => {
				// 	//联网失败, 结束加载
				// 	this.mescroll.endErr();
				// })
			},
			changeTab(e) {
				if (e == 0) {
					this.$func.jump('/yCreate/pages/goodsManagement')
				} else if (e == 1) {
					this.$func.jump('/yCreate/pages/orderManagement')
				} else if (e == 2) {
					this.$func.jump('/yCreate/pages/reviewOrder')
				} else if (e == 4) {
					this.$func.jump('/wNew/subPages/technician/tabBar/mine')
				}
			}
		}
	}
</script>

<style>
	page {
		width: 100%;
		padding: 0 33rpx;
		box-sizing: border-box;
	}
</style>
<style lang="scss" scoped>
	@import url(../../components/common.css);
	.m-t-30 {
		margin-top: 30rpx;
	}

	.item {
		padding: 0 30rpx 31rpx;
		background: #fff;
		border-radius: 10rpx;
		margin-top: 30rpx;

		.top {
			padding: 30rpx 0;
			border-bottom: 1rpx solid #DFDFDF;

			.del {
				width: 36rpx;
				height: 36rpx;
			}

			.edit {
				width: 34rpx;
				height: 34rpx;
				margin-left: 28rpx;
			}
		}

		.bot {
			padding-top: 30rpx;

			.zi {
				font-size: 28rpx;
				color: #222;
			}

			.address {
				font-size: 24rpx;
				color: #222;
				margin-top: 20rpx;
				line-height: 40rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 3;
				-webkit-box-orient: vertical;
				height: 110rpx;
			}

			.tit {
				font-size: 28rpx;
				font-weight: bold;
				color: #222;
			}

			.price {
				font-size: 28rpx;
				color: #222;
			}
		}
	}

	.btn {
		width: 630rpx;
		height: 80rpx;
		font-size: 28rpx;
		color: #FFF;
		margin: 0 auto;
		margin-top: 240rpx;
		background: linear-gradient( 98deg, #5D64CA 0%, #6F9BDF 100%);
		border-radius: 40rpx;
		position: fixed;
		bottom: 150rpx;
		left: 60rpx;
		right: 60rpx;
		z-index: 999;
	}
	.text-cut-four {
		text-overflow: ellipsis;
		white-space: normal;
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 4;
		-webkit-box-orient: vertical;
	}
</style>